<?php
namespace  Aitels\Foundation\Annotation;


class RouteAnnotation extends Annotation implements AnnotationInterface
{
    public const NAME = 'route';

    public function patten(): string
    {
        return '/@Route\((.+)\)/';
    }

    public function processMatches(array $matches)
    {
        $definitions = [];
        foreach ($matches[1] as $inParentheses) {
            $definition =$this->extractToParts($inParentheses);
            $parsed = [];
            foreach ($definition as $part) {

                list($left, $right) = explode('=', $part);
                if ($this->isJson($right)) {
                    $right = $this->parseJson($right);
                }
                $parsed[$left] = $right;
            }
            $definitions[] = $parsed;
        }
        return $definitions;
    }



}